import React from 'react';
import { useHistory } from "react-router-dom";
import { List, Button } from 'antd-mobile';

import Txt from "../../../components/txt/Txt";

import './userList.less';
import man from '../../../libs/img/user/man.png';
import woman from '../../../libs/img/user/woman.png';

const Item = List.Item;
const Brief = Item.Brief;


function UserList(props) {
  let history = useHistory();
  // let query  = new URLSearchParams(useLocation().search);
  let userMsg = user=>{
    history.push(`/user/edit?type=edit&id=${user.customerCrmId}`);
  }
  return (
    <div className='v-user-search'>
      <Txt className='g-p10'>提醒：共找到{props.list.length}位顾客，请确定顾客信息后在绑定此微信号</Txt>
      <List id='list'>
        {props.list.map((item,idx)=>(
          <Item className='g-p10 h-item g-mt10'
                key={idx}
                extra={<Button type="primary" size="small" inline onClick={()=>userMsg(item)}>预约</Button>}
                thumb={<img src={item.gender>1?woman:man} style={{width:50,height:50}} className='g-round' alt="UserImg"/>}>
            {item.customerName}
            <Brief>
              <p>顾客id: {item.customerCrmId}</p>
              <p>门诊号：{item.mzcode}</p>
            </Brief>
          </Item>
        ))}
      </List>
    </div>
  )
}

export default UserList;